S:=$(wildcard *.s)
C:=$(wildcard *.c)

ALL:= led.bin

ELF:= led.elf

OBJS := $(S:%.s=%.o)
OBJS += $(C:%.c=%.o)

$(ALL):$(ELF)
	arm-linux-gnueabihf-objcopy -O binary -S -g $? $@
	arm-linux-gnueabihf-objdump -D $? > led.dis

$(ELF):$(OBJS)
	arm-linux-gnueabihf-ld -Timx6u.lds $^ -o $@

%.o:%.c
	arm-linux-gnueabihf-gcc -Wall -nostdlib -c -O2 -o $@ $<

%.o:%.s
	arm-linux-gnueabihf-gcc -Wall -nostdlib -c -O2 -o $@ $<

imx:$(ALL)
	./imxdownload $^ ./imx 

clear:
	rm -rf *.o led.bin led.elf led.dis  imx
